package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResHuman;

public class ErspResHumanDao extends JActiveTable {
	public ErspResHumanDao() {
		this.setDBTableName("ersp_res_human");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("res_id", "res_id", ActiveField.ftString, 36));
		AddField(new JActiveField("res_gender", "res_gender", ActiveField.ftString, 4));
		AddField(new JActiveField("res_birthdate", "res_birthdate", ActiveField.ftString, 20));
		AddField(new JActiveField("res_proname", "res_proname", ActiveField.ftString, 100));
		AddField(new JActiveField("res_prozone", "res_prozone", ActiveField.ftInteger));
		AddField(new JActiveField("res_viewtype", "res_viewtype", ActiveField.ftInteger));
		AddField(new JActiveField("res_requirement", "res_requirement", ActiveField.ftString, 200));

		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
		setDbKeyFields("id");
	}

	public int add(ErspResHuman vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("res_gender", vo.getRes_gender());
		setFieldValue("res_gender", vo.getRes_gender());
		setFieldValue("res_proname", vo.getRes_proname());
		setFieldValue("res_prozone", vo.getRes_prozone());
		setFieldValue("res_certtype", vo.getRes_certtype());
		setFieldValue("res_viewtype", vo.getRes_viewtype());
		setFieldValue("res_requirement", vo.getRes_requirement());

		return DBManager.ExecSQL(this.getSQL());
	}

	public String getSQL(ErspResHuman vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("res_gender", vo.getRes_gender());
		setFieldValue("res_gender", vo.getRes_gender());
		setFieldValue("res_proname", vo.getRes_proname());
		setFieldValue("res_prozone", vo.getRes_prozone());
		setFieldValue("res_viewtype", vo.getRes_viewtype());
		setFieldValue("res_certtype", vo.getRes_certtype());
		setFieldValue("res_requirement", vo.getRes_requirement());
		return this.getSQL();
	}
}
